<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title><?php echo $OJ_NAME?></title>  
    <?php include("template/$OJ_TEMPLATE/css.php");?>	    


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
    <div class="container">
        <?php include("template/$OJ_TEMPLATE/nav.php");?>
        <div class="jumbotron col-md-12">
            <table id=statics class="table table-striped">
                <caption class="col-md-12">
                    <?php
                        echo $user."-".htmlentities($nick,ENT_QUOTES,"UTF-8");
                        //echo "<a href=mail.php?to_user=$user>$MSG_MAIL</a>";
                    ?>
                </caption>
                <tr>
                    <td width=12%>排名</td>
                    <td width=22% align=center><?php echo $Rank?></td>
                    <td width=66% align=center>题目提交数和题目和正确数统计</td>
                </tr>
                <tr>
                    <td>完成题目数</td>
                    <td align=center>
                        <a href='status.php?user_id=<?php echo $user?>&jresult=4'><?php echo $AC?></a>
                    </td>

                    <!--统计图-->
                    <td rowspan=14 align=center>
                        <script language='javascript'>
                            function p(id,c){
                                document.write("<a href=problem.php?id="+id+">"
                                    +id+" </a>(<a href='status.php?user_id=<?php echo $user?>&problem_id="
                                    +id+"'>"+c+"</a>)");
                            }

                            <?php
                            $sql="SELECT `problem_id`,count(1) from solution where `user_id`=? and result=4 group by `problem_id` ORDER BY `problem_id` ASC";
                            if ($result=pdo_query($sql,$user,$user)){
                                foreach($result as $row) {
                                    echo "p($row[0],$row[1]);";
                                }
                            }
                            ?>
                        </script>
                        <div id=submission style="width:49rem;height:20rem"></div>
                    </td>
                </tr>
                <tr>
                    <td>提交数</td>
                    <td align=center><a href='status.php?user_id=<?php echo $user?>'><?php echo $Submit?></a></td>
                </tr>
                <?php
                foreach($view_userstat as $row){
                    echo "<tr ><td>".$jresult[$row[0]]."<td align=center><a href=status.php?user_id=$user&jresult=".$row[0]." >".$row[1]."</a></tr>";
                }
                ?>
                <tr id=pie>
                    <td>统计<td>
                        <div id='PieDiv' style='position:relative;height:105px;width:120px;'></div>
                </tr>
                <tr ><td>学校:<td align=center><?php echo $school?></tr>
                <tr ><td>邮箱:<td align=center><?php echo $email?></tr>
            </table>
        </div>
        <?php if( isset($_SESSION['administrator']) ) {?>
            <div class="jumbotron col-md-12">
                <table class="col-md-12">
                    <tr class=toprow><th>用户ID<th>登陆状态<th>登录IP<th>登录时间</tr>
                    <tbody>
                    <?php
                        $cnt=0;
                        foreach($view_userinfo as $row){
                            if ($cnt)
                                echo "<tr class='oddrow'>";
                            else
                                echo "<tr class='evenrow'>";
                            for($i=0;$i<count($row)/2;$i++){
                                echo "<td>";
                                echo "\t".$row[$i];
                                echo "</td>";
                            }
                            echo "</tr>";
                            $cnt=1-$cnt;
                        }
                    ?>
                    </tbody>
                </table>
            </div>
        <?php } ?>
    </div>

    <!--饼图脚本代码-->
    <script type="text/javascript" src="include/wz_jsgraphics.js"></script>
    <script type="text/javascript" src="include/pie.js"></script>
    <script language="javascript">
        var y= new Array ();
        var x = new Array ();
        var dt=document.getElementById("statics");
        var data=dt.rows;
        var n = 0;
        for( var i=3; dt.rows[i].id!="pie"; i++ ) {
            // 标题
            n=dt.rows[i].cells[0];
            n=n.innerText || n.textContent;
            x.push(n);
            // 数量
            n=dt.rows[i].cells[1].firstChild;
            n=n.innerText || n.textContent;
            n=parseInt(n);
            y.push(n);
        }
        var mypie= new Pie("PieDiv");
        mypie.drawPie(y,x);
    </script>

    <!--曲线图-->
    <?php include("template/$OJ_TEMPLATE/js.php");?>
    <script language="javascript" type="text/javascript" src="include/jquery.flot.js"></script>
    <script type="text/javascript">
        $(function () {
            var d1 = [];
            var d2 = [];
            <?php
            foreach($chart_data_all as $k=>$d){
            ?>
            d1.push([<?php echo $k?>, <?php echo $d?>]);
            <?php
            }
            ?>

            <?php
            foreach($chart_data_ac as $k=>$d) {
            ?>
            d2.push([<?php echo $k?>, <?php echo $d?>]);
            <?php
            }
            ?>
            $.plot($("#submission"), [
                    {label:"提交总数", data:d1, lines: { show: true }},
                    {label:"正确总数", data:d2, lines: {show:true}} ],

                {
                    xaxis: {
                        mode: "time",
                        timeformat: "%y/%0m/%0d",
                        //, max:(new Date()).getTime()
                        // ,min:(new Date()).getTime()-100*24*3600*1000
                    },
                    grid: {
                        backgroundColor: { colors: ["#fff", "#333"] }
                    }
                });
        });
    </script>
  </body>
</html>
